<template>
  <div class="item" @click="to">
    <p class="id-hide">1</p>
    <router-link to="" class="hotsale-item">
      <div class="img-wrapper">
        <img :src="imgurl" alt="你好" />
      </div>
      <h4>{{ name }}</h4>
    </router-link>
    <p class="info">
      <span class="price">
        <em>￥</em>
        {{ price }}
      </span>
      <span class="sales">{{ buyer }}人购买</span>
    </p>
  </div>
</template>

<script>
export default {
  props: {
    id: {
      type: String,
      required: true
    },
    name: {
      type: String
    },
    url: {
      type: String,
      required: true
    },
    price: {
      type: Number
    },
    buyer: {
      type: Number
    }
  },
  data() {
    return {
      imgurl: '/api' + this.url
    }
  },
  methods: {
    to() {
      this.$router.push(`/desploy/${this.id}`)
    }
  }
}
</script>

<style lang="less" scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.item {
  border-radius: 12px;
  padding: 15px 20px;
  margin: 0 0 2px 7px;
  color: #6c6c6c;
  width: 100%;
  height: 319px;
  position: relative;
  place-content: center center;
}

.item:hover {
  box-shadow: 1px 1px 15px rgba(0, 0, 0, 0.1);
}

.img-wrapper {
  width: 215px;
  height: 215px;
  transform: translateX(5px);
  border-radius: 12px;
  background-color: rgba(0, 0, 0, 0.2);
  overflow: hidden;
}
.img-wrapper img {
  display: block;
  border-radius: 12px;
  width: 100%;
  height: 100%;
  background: #fff;
}
.img-wrapper:hover img {
  opacity: 0.8;
}

.hotsale-item h4 {
  margin-top: 9px;
  line-height: 22px;
  height: 44px;
  font-size: 16px;
  color: #333;
  font-weight: normal;
  transition: color 0.3s;
  overflow: hidden;
  text-overflow: -o-ellipsis-lastline;
  text-decoration: none;
}

.item:hover h4 {
  color: #ff5000;
}
.id-hide {
  display: none;
  color: #000;
}
em {
  font-size: 12px;
  font-style: normal;
}
.price {
  float: left;
  color: #f40;
  font-size: 20px;
  height: 22px;
  line-height: 22px;
}

.sales {
  height: 26px;
  line-height: 26px;
  vertical-align: bottom;
  margin-left: 4px;
  color: #999;
  font-size: 14px;
}
</style>
